package parabullgame;


import java.awt.Color;

import static org.lwjgl.opengl.GL11.*;

public class DrawUtil {

    /**
     * 
     * @param x
     * @param y
     * @param width
     * @param height
     * @param fg 
     */
    static void line(int x, int y, int x2, int y2, Color fg) {
        glColor3f(fg.getRed() / 255f * 1.3f, fg.getGreen() / 255f * 1.3f, fg.getBlue() / 255f * 1.3f);

        glBegin(GL_LINES);
        glVertex2f(x, y);
        glVertex2f(x2, y2);
        glEnd();


    }

    static void guiRect(int x, int y, int width, int height, Color fg, boolean pressed) {
        if (pressed) {
            glColor3f(fg.getRed() / 255f * .7f, fg.getGreen() / 255f * .7f, fg.getBlue() / 255f * .7f);
        }
        else {
            glColor3f(fg.getRed() / 255f * 1.3f, fg.getGreen() / 255f * 1.3f, fg.getBlue() / 255f * 1.3f);
        }
        
        glBegin(GL_QUADS);
        glVertex2f(x, y);
        glVertex2f(x + width, y);
        glVertex2f(x + width - 2, y + 2);
        glVertex2f(x, y + 2);
        glVertex2f(x, y + 2);
        glVertex2f(x, y + height);
        glVertex2f(x + 2, y + height - 2);
        glVertex2f(x + 2, y + 2);
        glEnd();

        if (pressed) {
            glColor3f(fg.getRed() / 255f * 1.3f, fg.getGreen() / 255f * 1.3f, fg.getBlue() / 255f * 1.3f);
        }
        else {
            glColor3f(fg.getRed() / 255f * .7f, fg.getGreen() / 255f * .7f, fg.getBlue() / 255f * .7f);
        }

        glBegin(GL_QUADS);
        glVertex2f(x + width, y + height);
        glVertex2f(x, y + height);
        glVertex2f(x + 2, y + height - 2);
        glVertex2f(x + width, y + height - 2);
        glVertex2f(x + width, y);
        glVertex2f(x + width, y + height - 2);
        glVertex2f(x + width - 2, y + height - 2);
        glVertex2f(x + width - 2, y + 2);
        glEnd();

        glColor3f(fg.getRed() / 255f, fg.getGreen() / 255f, fg.getBlue() / 255f);

        glBegin(GL_QUADS);
        glVertex2f(x + 2, y + 2);
        glVertex2f(x + width - 2, y + 2);
        glVertex2f(x + width - 2, y + height - 2);
        glVertex2f(x + 2, y + height - 2);
        glEnd();
    }

    /**
     * Draws a circle
     * @param x
     * @param y
     * @param rad
     * @param fg 
     */
    static void circle(int x, int y, int rad, Color fg) {
        glColor3f(fg.getRed() / 255f * 1.3f, fg.getGreen() / 255f * 1.3f, fg.getBlue() / 255f * 1.3f);


        glColor3f(fg.getRed() / 255f, fg.getGreen() / 255f, fg.getBlue() / 255f);

        glBegin(GL_POLYGON);
        for (double i = 0; i < 360; i += 1 / (double) (rad / 10)) {
            glVertex2f(x + (float) Math.cos(i) * rad, y + (float) Math.sin(i) * rad);
        }
        glEnd();
    }
}
